<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:ez="http://java.sun.com/jsf/composite/ezcomp"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

    <body>

        <ui:composition template="/resources/template/template.xhtml">

            <ui:define name="content">
                <h:form id="form">

                    <p:panel header="Manage Investigation Report Items" >
                        <p:panelGrid columns="2" styleClass="alignTop" >
                            <p:panelGrid columns="1" id="filters" >
                                <h:panelGrid columns="2" >
                                    <p:commandButton value="Previous" id="btnPre"
                                                     action="#{investigationItemController.previousInvestigation()}"
                                                     process="@this" ajax="false"
                                                     update="acPt tbl filters"  disabled="#{investigationItemController.currentInvestigation eq null}"
                                                     ></p:commandButton>
                                    <p:commandButton value="Next" disabled="#{investigationItemController.currentInvestigation eq null}"
                                                     action="#{investigationItemController.nextInvestigation()}"
                                                     process="@this" ajax="false"
                                                     update="acPt tbl filters" id="btnNext"
                                                     ></p:commandButton>

                                </h:panelGrid>
                                <p:outputLabel value="Search Investigation" ></p:outputLabel>
                                <p:autoComplete widgetVar="aPt" id="acPt" forceSelection="true" converter="ixcon"
                                                value="#{investigationItemController.currentInvestigation}" 
                                                completeMethod="#{investigationController.completeInvestigationsOfCurrentInstitution}" 
                                                var="apt" itemLabel="#{apt.name}" 
                                                itemValue="#{apt}" size="30" maxResults="10"  style="width: 400px;">
                                    <p:column headerText="Name" >
                                        <h:outputLabel value="#{apt.name}" ></h:outputLabel>
                                    </p:column>
                                    <p:column headerText="Code" >
                                        <h:outputLabel value="#{apt.code}" ></h:outputLabel>
                                    </p:column>
                                    <p:column headerText="Printing Name" >
                                        <h:outputLabel value="#{apt.printName}" ></h:outputLabel>
                                    </p:column>
                                    <p:column headerText="Fill Name" >
                                        <h:outputLabel value="#{apt.fullName}" ></h:outputLabel>
                                    </p:column>
                                    <p:ajax event="itemSelect" process="acPt" 
                                            update="tbl filters"/>
                                </p:autoComplete> 
                                <p:commandButton id="btnEditDetails" value="Delete Selected" ajax="false"
                                                 action="#{investigationItemController.retireSelectedItems}"
                                                 disabled="#{investigationItemController.current eq null}">
                                </p:commandButton>


                                
                            </p:panelGrid>
                            <p:panelGrid columns="1" >
                                <p:dataTable id="tbl" value="#{investigationItemController.items}" var="ii"
                                             rowKey="#{ii.id}" selection="#{investigationItemController.selectedItems}">

                                    <p:column selectionMode="multiple" ></p:column>
                                    <p:column headerText="ID"  >
                                        <p:outputLabel value="#{ii.item.id}" ></p:outputLabel>
                                    </p:column>
                                    <p:column headerText="Name"  >
                                        <p:outputLabel value="#{ii.name}" ></p:outputLabel>
                                    </p:column>
                                    <p:column headerText="Type" sortBy="#{ii.ixItemType}" filterBy="#{ii.ixItemType}">
                                        <p:outputLabel value="#{ii.ixItemType}" ></p:outputLabel>
                                    </p:column>
                                    <p:column headerText="Automated" >
                                        <p:outputLabel value="#{ii.automated?'Automated':'Not automated'}" ></p:outputLabel>
                                    </p:column>
                                    <p:column headerText="Test Componant" >
                                        <p:outputLabel value="#{ii.sampleComponent.name}" ></p:outputLabel>
                                    </p:column>
                                    <p:column headerText="Machine" >
                                        <p:outputLabel value="#{ii.machine.name}" ></p:outputLabel>
                                    </p:column>
                                    <p:column headerText="Test" >
                                        <p:outputLabel value="#{ii.test.name}" ></p:outputLabel>
                                    </p:column>
                                    <p:column headerText="Sample" >
                                        <p:outputLabel value="#{ii.sample.name}" ></p:outputLabel>
                                    </p:column>
                                    <p:column headerText="Tube" >
                                        <p:outputLabel value="#{ii.tube.name}" ></p:outputLabel>
                                    </p:column>
                                </p:dataTable>
                            </p:panelGrid>


                        </p:panelGrid>


                    </p:panel>

















                </h:form>

            </ui:define>

        </ui:composition>

    </body>
</html>
